{extend name="public:base"/}
{block name="main"}

<form class="layui-form" action="" method="POST">
        
        
        <div class="layui-form-item">
          <label class="layui-form-label">名称</label>
          <div class="layui-input-inline" style="width:350px;">
            <input type="hidden" name="roleid" value="{$info['roleid']}">
            <input type="text" name="name" required lay-verify="required" placeholder="名称" autocomplete="off" class="layui-input"  value="{$info['name']}">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">排序</label>
          <div class="layui-input-inline" style="width:350px;">
            <input type="number" name="px"  placeholder="排序" autocomplete="off" class="layui-input"  value="{$info['px']}">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">状态</label>
          <div class="layui-input-block">
            <input type="checkbox" name="status" lay-skin="switch" lay-text="启用|禁用" lay-filter="switchTest" value="1" {if condition="($info['status'] eq '1') OR ($info['status'] neq '0')"}checked=''{/if}>
            <div class="layui-unselect layui-form-switch" lay-skin="_switch">
            	<em>OFF</em><i></i>
            </div>
          </div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label"><b>权限列表</b></label>
        </div>
        {foreach $info['auto']  as $k=>$v}
   
        <div class="layui-form-item">
          <label class="layui-form-label">
            {$k}
          </label>
          <div class="layui-input-block">
            {foreach $v as $vo}
            <input type="checkbox" name="auto[{$k}][]" title="{$vo}" lay-skin="primary" lay-filter="ceshi"   value="{$vo}">
            {/foreach}
          </div>
        </div>
        {/foreach}
        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
          </div>
        </div>
</form>

<script type="text/javascript">
	layui.use(['form','layedit','upload'], function(){
	  var form = layui.form;
     
	  form.on('checkbox(ceshi)', function(data){

      if(data.elem.checked==true){

        $(data.othis).parents(".layui-form-item").find(".p input").attr("checked", true)

      }else{
        
      }
    /*console.log(data.elem); //得到checkbox原始DOM对象
    console.log(data.elem.checked); //是否被选中，true或者false
    console.log(data.value); //复选框value值，也可以通过data.elem.value得到
    console.log(data.othis); //得到美化后的DOM对象*/
  });  
	  
	});
</script>

{/block}